<?php
namespace Tbf\Component\Crypto\Password\Hash;
use \Tbf\Component\Crypto\CryptoRandUtil;
use Tbf\Component\Crypto\Password\HashInterface;
class BcryptHash implements HashInterface
{
    public function hash($plain)
    {
        $salt = bin2hex(CryptoRandUtil::binary(12));
        //$b = microtime(true);
        $hashed = crypt($plain,'$2a$10$'.$salt.'$');
        //echo (microtime(true)-$b)."\n";
        return $hashed;
    }
}
